<%--
  Created by IntelliJ IDEA.
  User: Hsiao
  Date: 2023/11/21
  Time: 13:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>index</title>
    <script src="${pageContext.request.contextPath}/static/js/jquery-3.7.1.js"></script>
    <script>
        $(function () {
            $("#btn").click(() => {
                console.log("click")
                // todo 406 (Not Acceptable)
                $.get("${pageContext.request.contextPath}/api/users/list", function (data) {
                    console.log(data)
                    let html = "";
                    for (let i = 0; i < data.length; i++) {
                        html += "<tr>" +
                            "<td>" + data[i].id + "</td>" +
                            "<td>" + data[i].username + "</td>" +
                            "<td>" + data[i].password + "</td>" +
                            "</tr>"
                    }
                    $("#content").html(html);
                });
            })
        });

    </script>
</head>
<body>
<h2>
    <a href="${pageContext.request.contextPath}/api/users/all">all-不分离</a>

    <%--    <button id="btn">list-分离</button>--%>
    <input type="button" value="list-分离" id="btn"/>
    <table>
        <tr>
            <td>id</td>
            <td>username</td>
            <td>password</td>
        </tr>
        <tbody id="content"></tbody>
    </table>
</h2>
</body>
</html>
